<div bsModal #actionModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="actionModal"
  aria-hidden="true" [config]="{backdrop: false}">
  <div class="modal-dialog">
    <div class="modal-content">
      <form *ngIf="active" #actionForm="ngForm" novalidate (ngSubmit)="save()">

        <div class="modal-header">
          <h4 class="modal-title">
            <span>调整库存减操作</span>
          </h4>
          <button type="button" class="close" (click)="close()" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>

        <div class="modal-body">
          <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
            <h5 class="mb-4">
              <i class="fa fa-list"></i> 库存信息</h5>
            <p-table [value]="details" selectionMode="single" [(selection)]="selectedDetail" dataKey="positionId">
              <ng-template pTemplate="header">
                <tr>
                  <th width="40px"></th>
                  <th width="80px">库存数量</th>
                  <th width="200px">位置</th>
                </tr>
              </ng-template>
              <ng-template pTemplate="body" let-rowData>
                <tr [pSelectableRow]="rowData">
                  <td width="40px">
                    <p-tableRadioButton [value]="rowData"></p-tableRadioButton>
                  </td>
                  <td width="80px">{{rowData.canUsedQuantity}}</td>
                  <td width="200px">{{rowData.locationName}}</td>
                </tr>
              </ng-template>
            </p-table>
          </div>
          <h5 class="mb-4" style="margin-top: 20px;">
            <i class="fa fa-list"></i> 其他信息</h5>
          <label>数量
            <span class="text-danger">*</span>
          </label>
          <div class="form-group form-md-line-input form-md-floating-label no-hint">
            <input class="form-control" name="quantity" [ngClass]="{'edited': quantity}" [(ngModel)]="quantity"
              required>
          </div>
          <label>备注
          </label>
          <div class="form-group form-md-line-input form-md-floating-label no-hint">
            <textarea class="form-control" type="text" name="remark" [ngClass]="{'edited': remark}" [(ngModel)]="remark"
              rows="2"></textarea>
          </div>
        </div>

        <div class="modal-footer">
          <button [disabled]="saving" type="button" class="btn btn-default" (click)="close()">{{l("Cancel")}}</button>
          <button type="submit" class="btn btn-primary blue" [disabled]="!(actionForm.form.valid) || !selectedDetail.positionId"
            [buttonBusy]="saving" [busyText]="'调整库存减中...'">
            <i class="fa fa-hourglass-half"></i>
            <span>调整库存减</span>
          </button>
        </div>

      </form>

    </div>
  </div>
</div>
